<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
  <title>打印</title>
  <!-- Bootstrap -->
  <meta charset="utf-8">
  <link rel="stylesheet" href="./word.css?v=202002905">
  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]>
  <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body>

<a class="print" href="javascript:;" onclick="preview();">打印文件</a>
<!-- <a class="printa" href="javascript:;" onclick="preview1();">打印公章备案表</a>  -->
<!--startprint-->
<div class="container a4-endwise" id="test" style="page-break-before:always">
  <p class="title" id="titleWord"></p>
  <div class="textbody">
    <div id="printBody">
    </div>
    <div class="footercopy">
      <p id="studentName">学生姓名： <span>--</span></p>
      <p>家长签名：
        <img src=""
             alt="" class="showImgCheck" id="studentImg"></p>
      <p id="studentTime">签名时间： <span></span></p>
    </div>
  </div>
</div>
<!--endprint1--> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<!--<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>-->
<script>
	// /admin/printing/notice 通知打印
  console.log('当前链接内容是什么参数id列表', window.location.href)

  var http_ = window.location.href;
  // var id_ = http_[1].split('=')[1];
  // var html_ = $("#box").html(), type_ = $("#type").html();
  // $("#type_").html(type_)
  var theRequest = new Object();
   if (http_.indexOf("?") != -1) {
    var strs = http_.split('?');
     var str = strs[1].split("&");
      for(var i = 0; i < str.length; i ++) {
        theRequest[str[i].split("=")[0]]=(str[i].split("=")[1]);
      }
   }

  var http_ = ''; // type 1问卷 2通知
  if(theRequest['type']==1){
    http_ = '/admin/printing/questionnaire';
  } else{
    http_ = '/admin/printing/notice';
  }
$.post(http_,{id:theRequest['id']},function(res){
  console.log(res)
  if(theRequest['type']==1){
    $("#printBody").html(res.detail.commitment)
    $("#titleWord").text('校园承诺书')
  } else{
    $("#printBody").html(res.detail.body)
    $("#titleWord").text(res.detail.title)
  }

  $("#studentName span").text(res.detail.student_name)
  $("#studentImg").attr('src', res.detail.pic)
  $("#studentTime span").text(res.detail.sign_time.split(' ')[0])
})
  function preview() {
    bdhtml = window.document.body.innerHTML;//获取当前页的html代码
    sprnstr = "<!--startprint-->";//设置打印开始区域
    eprnstr = "<!--endprint-->";//设置打印结束区域
    prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr) + 18); //从开始代码向后取html
    prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));//从结束代码向前取html
    window.document.body.innerHTML = prnhtml;
    console.log(prnhtml);
    // pagesetup_null()
    //打印之前设置IE打印时不打印页眉 、页脚
    window.print();
    window.document.body.innerHTML = bdhtml;
  }

  // function preview1()
  // {
  //     bdhtml=window.document.body.innerHTML;//获取当前页的html代码
  //     sprnstr="<!--startprint1-->";//设置打印开始区域
  //     eprnstr="<!--endprint1-->";//设置打印结束区域
  //     prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
  //     prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
  //     window.document.body.innerHTML=prnhtml;
  //     console.log(prnhtml);
  //     // pagesetup_null()
  //     //打印之前设置IE打印时不打印页眉 、页脚
  //     window.print();
  //     window.document.body.innerHTML=bdhtml;
  // }
  var hkey_root, hkey_path, hkey_key;
  hkey_root = "HKEY_CURRENT_USER", hkey_path = "\Software\Microsoft\Internet Explorer\PageSetup\ "

  function pagesetup_null() {
    try {
      var RegWsh = new ActiveXObject("WScript.Shell");
      hkey_key = "header";
      RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
      hkey_key = "footer";
      RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "")
    } catch (e) {
    }
  }

</script>
</body>
</html>
